package com.sdap2.common.model;

import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class ApiResult<T> {
    private Integer code;
    private String message;
    private T data;
    private Long timestamp = System.currentTimeMillis();

    public static <T> ApiResult<T> success() {
        return new ApiResult<T>().setCode(200).setMessage("操作成功");
    }

    public static <T> ApiResult<T> success(T data) {
        return new ApiResult<T>().setCode(200).setMessage("操作成功").setData(data);
    }

    public static <T> ApiResult<T> error(String message) {
        return new ApiResult<T>().setCode(500).setMessage(message);
    }

    public static <T> ApiResult<T> error(Integer code, String message) {
        return new ApiResult<T>().setCode(code).setMessage(message);
    }
} 